package com.itheima.controller;

import com.itheima.service.HistoryService;
import com.itheima.dto.HistoryDto;
import com.itheima.vo.HistoryVo;
import com.itheima.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author :wujunjie
 * createTime :2022-12-29 10:02
 * description :
 */
@RestController
@RequestMapping("/api/v1/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @PostMapping("load")
    public Result load(){
        List<HistoryVo> historyVos=historyService.load();
        return Result.success(historyVos);
    }

    @PostMapping("del")
    public Result del(@RequestBody HistoryDto historyDto){
        Boolean del=historyService.del(historyDto.getId());
        if (del){
            return Result.success("success");
        }
        return Result.error();
    }
}
